<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%
    List l = new ArrayList();
    l.add(new Date());
    l.add(new Date());
    l.add(new Date());
    l.add(new Date());
    l.add(new Date());
    l.add(new Date());
    request.setAttribute("lista", l);
    Map m = new HashMap();
    m.put("uno", 1);
    m.put("dos", 2);
    request.setAttribute("mapa", m);

    request.setAttribute("cadena", "<>&/'\"");
%>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>${param.edad}</h1>
        <c:forEach var="registro" items="<%= request.getAttribute("lista")%>">
            ${registro.year+1900}-${registro.month+1}-${registro.date}
        </c:forEach>
        <c:forEach var="registro" items="${requestScope.lista}">
            ${registro.year+1900}-${registro.month+1}-${registro.date}            
        </c:forEach>

        <br/>
        <c:set var="campo" value="month"/>
        ${requestScope.lista[0][campo]}
        <br/>
        <c:set var="campo" value="uno"/>
        ${requestScope.mapa[campo]}
        <br/>
        ${header["Host"]}
        <br/>
        <c:if test="${not empty param.edad}">
            Existe edad
        </c:if>
        <br/>
        ${fn:length(requestScope.lista)}
        <br/>
        <c:out escapeXml="true" value="${requestScope.cadena}"/>
        <%--${requestScope.cadena}--%>
        <br/>
        <c:catch var="err">
            <textarea>
                <c:import url="http://java.sun.com"/>
            </textarea>
        </c:catch>
        <c:if test="${not empty err}">
            Could not connect to Java web site.
        </c:if>
        <br/>
        <c:forEach items="${requestScope.lista}" var="r" begin="1" end="5" step="2" varStatus="estado">
            ${r.year}--${estado.index}--${estado.count}--${estado.first}--${estado.last} <br/>
        </c:forEach>
        <br/>
        <c:set var="users">Fred,Joe,Mary</c:set>
        <c:forTokens var="name" items="${users}"
                     delims=",">
            <c:out value="${name}"/><br/>
        </c:forTokens>
        <br/>
        <fmt:setLocale scope="session" value="fr_CA"/>
        <c:forEach items="${requestScope.lista}" var="r">
            <fmt:formatDate pattern="dd/MM/yyyy" value="${r}"/> 
            <fmt:formatDate dateStyle="long" timeStyle="long" type="both" value="${r}"/> 
            <br/>
        </c:forEach>        
        <br/>
        <c:set var="numero" value="22.456"/>
        <fmt:formatNumber value="${numero}" maxFractionDigits="1" minIntegerDigits="3"/>
        
    </body>
</html>
